package com.pro.controller;

import com.pro.pojo.JsLoginRecord;
import com.pro.pojo.JsonData;
import com.pro.service.JsLoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsLoginRecordController
 * Package:com.pro.controller
 * Description: 登录日志controller
 *
 * @Date:2021/11/4 上午 9:36
 * @Author:WYH
 */
@Controller
@RequestMapping("/loginRecord")
public class JsLoginRecordController {

    @Autowired
    private JsLoginRecordService jsLoginRecordService;

    /**
     * @author WYH
     * @date 2021/11/7 下午 6:38
     * @content : 查询登录日志的所有内容 进行分页查询
     */
    @RequestMapping("/getJsJsLoginRecord")
    @ResponseBody
    public JsonData getJsJsLoginRecord(Integer page,Integer limit) {
        List<JsLoginRecord> list = jsLoginRecordService.getJsJsLoginRecord(page,limit);
        int count = jsLoginRecordService.count();
        return list!=null?JsonData.buildSuccess(list,count):JsonData.buildError("服务端错误");
    }

    /**
     * @author WYH
     * @date 2021/11/7 下午 6:38
     * @content : 记录所有登录值日的总个数
     */
    public JsonData count() {
        int i = jsLoginRecordService.count();
        return i >= 0 ?JsonData.buildSuccess(i):JsonData.buildError("服务端错误");
    }
}
